#%RAML 1.0

title: e-BookMobile API
baseUri: http://localhost:8081
version: v1

types:
  book: !include book.schema
  books: !include books.schema

traits:
  facets: !include raml-util/traits/facets.raml

/rmbtests:
  /books:
    get:
      is: [facets]
      queryParameters:
        author:
          displayName: Author
          type: string
          description: An author's full name
          example: Mary Roach
          required: true
        publicationDate:
          displayName: Pub Date
          type: date-only
          description: The date released for the first time in the US
          example: 1984-07-10
          required: true
        rating:
          displayName: Rating
          type: number
          description: Average rating (1-5) submitted by users
          example: 3.14
          required: false
        edition:
          displayName: Edition
          type: integer
          example: 2
          required: false
        isbn:
          displayName: ISBN
          type: string
          minLength: 10
          example: 0321736079?
      responses:
        200:
         body:
           application/json:
            schema: book
            example:
              strict: false
              value: |
               {
                 "data": {
                   "id": "SbBGk",
                   "title": "Stiff: The Curious Lives of Human Cadavers",
                   "description": "aaaaaa",
                   "genre": "science",
                   "author": "Mary Roach",
                   "link": "http://e-bookmobile.com/books/Stiff"
                 },
                 "success": true,
                 "status": 200,
                 "metadata": {
                   "createdDate": "2017-04-01T23:11:00.000Z",
                   "createdByUserId": "dee12548-9cee-45fa-bbae-675c1cc0ce3b"
                 }
               }

    put:
      queryParameters:
        access_token:
          displayName: Access Token
          type: number
          description: Token giving you permission to make call
          required: true
    post:
      body:
        application/json:
          schema: book
      responses:
        201:
          body:
            application/json:
              example: !include examples/book.sample
          headers:
            Location:
  /test:
    post:
      body:
        application/json:
          schema: book
      responses:
        201:
          headers:
            Location:
          body:
            application/json:
        400:
          body:
            text/plain:
        422:
          body:
            text/plain:
        500:
          body:
            text/plain:
    get:
      queryParameters:
        query:
          displayName: CQL query
          type: string
          description: CQL query
          example: title=water
          required: false
      responses:
        200:
          body:
            application/json:
              schema: books
        400:
          body:
             text/plain:
        422:
          body:
            text/plain:
        500:
          body:
            text/plain:
    options:
        description: "Preflight CORS for /rmbtests/test"
        responses:
          200:
            description: "Return with appropriate CORS headers"
  /testStream:
    post:
      body:
        application/octet-stream:
      responses:
        200:
          body:
            application/json:
        400:
          body:
            text/plain:
        500:
          body:
            text/plain:
